﻿using System;
using System.Collections.Generic;
using AspireFyh.ApiService.Entities;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal;

namespace AspireFyh.ApiService.Context;

public partial class MyDbContext : DbContext
{
    public MyDbContext()
    {
    }

    public MyDbContext(DbContextOptions<MyDbContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Account> Accounts { get; set; }

    public virtual DbSet<AccountCopy1> AccountCopy1s { get; set; }

    public virtual DbSet<AccountRole> AccountRoles { get; set; }

    public virtual DbSet<Alert> Alerts { get; set; }

    public virtual DbSet<AlertRule> AlertRules { get; set; }

    public virtual DbSet<ConfigInfo> ConfigInfos { get; set; }

    public virtual DbSet<ConfigInfoAggr> ConfigInfoAggrs { get; set; }

    public virtual DbSet<ConfigInfoBetum> ConfigInfoBeta { get; set; }

    public virtual DbSet<ConfigInfoTag> ConfigInfoTags { get; set; }

    public virtual DbSet<ConfigTagsRelation> ConfigTagsRelations { get; set; }

    public virtual DbSet<Device> Devices { get; set; }

    public virtual DbSet<Device1> Devices1 { get; set; }

    public virtual DbSet<DeviceGateway> DeviceGateways { get; set; }

    public virtual DbSet<DeviceRule> DeviceRules { get; set; }

    public virtual DbSet<DeviceStatistic> DeviceStatistics { get; set; }

    public virtual DbSet<DeviceType> DeviceTypes { get; set; }

    public virtual DbSet<DevicesCopy1> DevicesCopy1s { get; set; }

    public virtual DbSet<FuleInfo> FuleInfos { get; set; }

    public virtual DbSet<Gateway> Gateways { get; set; }

    public virtual DbSet<GroupCapacity> GroupCapacities { get; set; }

    public virtual DbSet<HisConfigInfo> HisConfigInfos { get; set; }

    public virtual DbSet<Measurement> Measurements { get; set; }

    public virtual DbSet<Menu> Menus { get; set; }

    public virtual DbSet<Menu1> Menus1 { get; set; }

    public virtual DbSet<Metric> Metrics { get; set; }

    public virtual DbSet<MetricGroup> MetricGroups { get; set; }

    public virtual DbSet<MonitorDevice> MonitorDevices { get; set; }

    public virtual DbSet<MonitorPoint> MonitorPoints { get; set; }

    public virtual DbSet<Oil> Oils { get; set; }

    public virtual DbSet<OilInfo> OilInfos { get; set; }

    public virtual DbSet<Organization> Organizations { get; set; }

    public virtual DbSet<OrganizationRole> OrganizationRoles { get; set; }

    public virtual DbSet<Parameter> Parameters { get; set; }

    public virtual DbSet<Permission> Permissions { get; set; }

    public virtual DbSet<Power> Powers { get; set; }

    public virtual DbSet<Role> Roles { get; set; }

    public virtual DbSet<Role1> Roles1 { get; set; }

    public virtual DbSet<RoleMenu> RoleMenus { get; set; }

    public virtual DbSet<Rule> Rules { get; set; }

    public virtual DbSet<RuleEntity> RuleEntities { get; set; }

    public virtual DbSet<Sensor> Sensors { get; set; }

    public virtual DbSet<SensorPoint> SensorPoints { get; set; }

    public virtual DbSet<Sensordata> Sensordatas { get; set; }

    public virtual DbSet<SensordatasCopy1> SensordatasCopy1s { get; set; }

    public virtual DbSet<SensorsCopy1> SensorsCopy1s { get; set; }

    public virtual DbSet<Sensorsstateinfo> Sensorsstateinfos { get; set; }

    public virtual DbSet<Server> Servers { get; set; }

    public virtual DbSet<Statistic> Statistics { get; set; }

    public virtual DbSet<TenantCapacity> TenantCapacities { get; set; }

    public virtual DbSet<TenantInfo> TenantInfos { get; set; }

    public virtual DbSet<UpdateFile> UpdateFiles { get; set; }

    public virtual DbSet<UpdateMessage> UpdateMessages { get; set; }

    public virtual DbSet<UpdateTask> UpdateTasks { get; set; }

    public virtual DbSet<Updatetask1> Updatetasks1 { get; set; }

    public virtual DbSet<User> Users { get; set; }

    public virtual DbSet<Warningdata> Warningdatas { get; set; }

//     protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
// #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
//         => optionsBuilder.UseMySql("server=localhost;port=3306;database=clouddb;uid=root;pwd=123456", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.39-mysql"));

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_0900_ai_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<Account>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("account");

            entity.HasIndex(e => e.OrganizationId, "FK819xqtmv5y59ky30f3um8lpp8");

            entity.HasIndex(e => e.Username, "UK_gex1lmaqpg0ir5g1f5eftyaa1").IsUnique();

            entity.HasIndex(e => e.Email, "email_uk").IsUnique();

            entity.HasIndex(e => e.Phone, "phone_uk").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.Email).HasColumnName("email");
            entity.Property(e => e.Expired)
                .HasComment("是否过期")
                .HasColumnType("datetime")
                .HasColumnName("expired");
            entity.Property(e => e.FirstLogin)
                .HasDefaultValueSql("b'1'")
                .HasColumnType("bit(1)")
                .HasColumnName("first_login");
            entity.Property(e => e.IsEnabled)
                .HasDefaultValueSql("b'1'")
                .HasComment("是否禁用")
                .HasColumnType("bit(1)")
                .HasColumnName("is_enabled");
            entity.Property(e => e.IsLocked)
                .HasDefaultValueSql("b'1'")
                .HasComment("是否锁定")
                .HasColumnType("bit(1)")
                .HasColumnName("is_locked");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.Password)
                .HasMaxLength(255)
                .HasColumnName("password");
            entity.Property(e => e.Phone).HasColumnName("phone");
            entity.Property(e => e.Username).HasColumnName("username");

            entity.HasOne(d => d.Organization).WithMany(p => p.Accounts)
                .HasForeignKey(d => d.OrganizationId)
                .HasConstraintName("FK819xqtmv5y59ky30f3um8lpp8");
        });

        modelBuilder.Entity<AccountCopy1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("account_copy1");

            entity.HasIndex(e => e.OrganizationId, "FK819xqtmv5y59ky30f3um8lpp8");

            entity.HasIndex(e => e.Username, "UK_gex1lmaqpg0ir5g1f5eftyaa1").IsUnique();

            entity.HasIndex(e => e.Email, "email_uk").IsUnique();

            entity.HasIndex(e => e.Phone, "phone_uk").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.Email).HasColumnName("email");
            entity.Property(e => e.Expired)
                .HasComment("是否过期")
                .HasColumnType("datetime")
                .HasColumnName("expired");
            entity.Property(e => e.FirstLogin)
                .HasDefaultValueSql("b'1'")
                .HasColumnType("bit(1)")
                .HasColumnName("first_login");
            entity.Property(e => e.IsEnabled)
                .HasDefaultValueSql("b'1'")
                .HasComment("是否禁用")
                .HasColumnType("bit(1)")
                .HasColumnName("is_enabled");
            entity.Property(e => e.IsLocked)
                .HasDefaultValueSql("b'1'")
                .HasComment("是否锁定")
                .HasColumnType("bit(1)")
                .HasColumnName("is_locked");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.Password)
                .HasMaxLength(255)
                .HasColumnName("password");
            entity.Property(e => e.Phone).HasColumnName("phone");
            entity.Property(e => e.Username).HasColumnName("username");

            entity.HasOne(d => d.Organization).WithMany(p => p.AccountCopy1s)
                .HasForeignKey(d => d.OrganizationId)
                .HasConstraintName("account_copy1_ibfk_1");
        });

        modelBuilder.Entity<AccountRole>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("account_role");

            entity.HasIndex(e => e.AccountId, "FK1f8y4iy71kb1arff79s71j0dh");

            entity.HasIndex(e => e.RoleId, "FKrs2s3m3039h0xt8d5yhwbuyam");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.AccountId).HasColumnName("account_id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.RoleId).HasColumnName("role_id");

            entity.HasOne(d => d.Account).WithMany(p => p.AccountRoles)
                .HasForeignKey(d => d.AccountId)
                .HasConstraintName("FK1f8y4iy71kb1arff79s71j0dh");

            entity.HasOne(d => d.Role).WithMany(p => p.AccountRoles)
                .HasForeignKey(d => d.RoleId)
                .HasConstraintName("FKrs2s3m3039h0xt8d5yhwbuyam");
        });

        modelBuilder.Entity<Alert>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("alert");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(255)
                .HasColumnName("device_name");
            entity.Property(e => e.Location)
                .HasMaxLength(255)
                .HasColumnName("location");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.ParaName)
                .HasMaxLength(255)
                .HasColumnName("para_name");
            entity.Property(e => e.Phone)
                .HasMaxLength(255)
                .HasColumnName("phone");
            entity.Property(e => e.RuleType)
                .HasColumnType("enum('WARNING','ALARM')")
                .HasColumnName("rule_type");
            entity.Property(e => e.Time)
                .HasMaxLength(6)
                .HasColumnName("time");
            entity.Property(e => e.Value).HasColumnName("value");
        });

        modelBuilder.Entity<AlertRule>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("alert_rule");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.LowerLimit).HasColumnName("lower_limit");
            entity.Property(e => e.LowerLimit1).HasColumnName("lowerLimit");
            entity.Property(e => e.MeasurementId).HasColumnName("measurement_id");
            entity.Property(e => e.MeasurementId1).HasColumnName("measurementId");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.MonitoringPointId).HasColumnName("monitoring_point_id");
            entity.Property(e => e.MonitoringPointId1).HasColumnName("monitoringPointId");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.OrganizationId1).HasColumnName("organizationId");
            entity.Property(e => e.Status).HasColumnName("status");
            entity.Property(e => e.Threshold).HasColumnName("threshold");
            entity.Property(e => e.UpperLimit).HasColumnName("upper_limit");
            entity.Property(e => e.UpperLimit1).HasColumnName("upperLimit");
        });

        modelBuilder.Entity<ConfigInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("config_info", tb => tb.HasComment("config_info"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => new { e.DataId, e.GroupId, e.TenantId }, "uk_configinfo_datagrouptenant").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("id")
                .HasColumnName("id");
            entity.Property(e => e.AppName)
                .HasMaxLength(128)
                .HasColumnName("app_name");
            entity.Property(e => e.CDesc)
                .HasMaxLength(256)
                .HasColumnName("c_desc");
            entity.Property(e => e.CSchema)
                .HasColumnType("text")
                .HasColumnName("c_schema");
            entity.Property(e => e.CUse)
                .HasMaxLength(64)
                .HasColumnName("c_use");
            entity.Property(e => e.Content)
                .HasComment("content")
                .HasColumnName("content");
            entity.Property(e => e.DataId)
                .HasComment("data_id")
                .HasColumnName("data_id");
            entity.Property(e => e.Effect)
                .HasMaxLength(64)
                .HasColumnName("effect");
            entity.Property(e => e.GmtCreate)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.GroupId).HasColumnName("group_id");
            entity.Property(e => e.Md5)
                .HasMaxLength(32)
                .HasComment("md5")
                .HasColumnName("md5");
            entity.Property(e => e.SrcIp)
                .HasMaxLength(20)
                .HasComment("source ip")
                .HasColumnName("src_ip");
            entity.Property(e => e.SrcUser)
                .HasComment("source user")
                .HasColumnType("text")
                .HasColumnName("src_user");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("租户字段")
                .HasColumnName("tenant_id");
            entity.Property(e => e.Type)
                .HasMaxLength(64)
                .HasColumnName("type");
        });

        modelBuilder.Entity<ConfigInfoAggr>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("config_info_aggr", tb => tb.HasComment("增加租户字段"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => new { e.DataId, e.GroupId, e.TenantId, e.DatumId }, "uk_configinfoaggr_datagrouptenantdatum").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("id")
                .HasColumnName("id");
            entity.Property(e => e.AppName)
                .HasMaxLength(128)
                .HasColumnName("app_name");
            entity.Property(e => e.Content)
                .HasComment("内容")
                .HasColumnName("content");
            entity.Property(e => e.DataId)
                .HasComment("data_id")
                .HasColumnName("data_id");
            entity.Property(e => e.DatumId)
                .HasComment("datum_id")
                .HasColumnName("datum_id");
            entity.Property(e => e.GmtModified)
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.GroupId)
                .HasComment("group_id")
                .HasColumnName("group_id");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("租户字段")
                .HasColumnName("tenant_id");
        });

        modelBuilder.Entity<ConfigInfoBetum>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("config_info_beta", tb => tb.HasComment("config_info_beta"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => new { e.DataId, e.GroupId, e.TenantId }, "uk_configinfobeta_datagrouptenant").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("id")
                .HasColumnName("id");
            entity.Property(e => e.AppName)
                .HasMaxLength(128)
                .HasComment("app_name")
                .HasColumnName("app_name");
            entity.Property(e => e.BetaIps)
                .HasMaxLength(1024)
                .HasComment("betaIps")
                .HasColumnName("beta_ips");
            entity.Property(e => e.Content)
                .HasComment("content")
                .HasColumnName("content");
            entity.Property(e => e.DataId)
                .HasComment("data_id")
                .HasColumnName("data_id");
            entity.Property(e => e.GmtCreate)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.GroupId)
                .HasMaxLength(128)
                .HasComment("group_id")
                .HasColumnName("group_id");
            entity.Property(e => e.Md5)
                .HasMaxLength(32)
                .HasComment("md5")
                .HasColumnName("md5");
            entity.Property(e => e.SrcIp)
                .HasMaxLength(20)
                .HasComment("source ip")
                .HasColumnName("src_ip");
            entity.Property(e => e.SrcUser)
                .HasComment("source user")
                .HasColumnType("text")
                .HasColumnName("src_user");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("租户字段")
                .HasColumnName("tenant_id");
        });

        modelBuilder.Entity<ConfigInfoTag>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("config_info_tag", tb => tb.HasComment("config_info_tag"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => new { e.DataId, e.GroupId, e.TenantId, e.TagId }, "uk_configinfotag_datagrouptenanttag").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("id")
                .HasColumnName("id");
            entity.Property(e => e.AppName)
                .HasMaxLength(128)
                .HasComment("app_name")
                .HasColumnName("app_name");
            entity.Property(e => e.Content)
                .HasComment("content")
                .HasColumnName("content");
            entity.Property(e => e.DataId)
                .HasComment("data_id")
                .HasColumnName("data_id");
            entity.Property(e => e.GmtCreate)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.GroupId)
                .HasMaxLength(128)
                .HasComment("group_id")
                .HasColumnName("group_id");
            entity.Property(e => e.Md5)
                .HasMaxLength(32)
                .HasComment("md5")
                .HasColumnName("md5");
            entity.Property(e => e.SrcIp)
                .HasMaxLength(20)
                .HasComment("source ip")
                .HasColumnName("src_ip");
            entity.Property(e => e.SrcUser)
                .HasComment("source user")
                .HasColumnType("text")
                .HasColumnName("src_user");
            entity.Property(e => e.TagId)
                .HasMaxLength(128)
                .HasComment("tag_id")
                .HasColumnName("tag_id");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("tenant_id")
                .HasColumnName("tenant_id");
        });

        modelBuilder.Entity<ConfigTagsRelation>(entity =>
        {
            entity.HasKey(e => e.Nid).HasName("PRIMARY");

            entity
                .ToTable("config_tags_relation", tb => tb.HasComment("config_tag_relation"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => e.TenantId, "idx_tenant_id");

            entity.HasIndex(e => new { e.Id, e.TagName, e.TagType }, "uk_configtagrelation_configidtag").IsUnique();

            entity.Property(e => e.Nid).HasColumnName("nid");
            entity.Property(e => e.DataId)
                .HasMaxLength(255)
                .HasComment("data_id")
                .HasColumnName("data_id");
            entity.Property(e => e.GroupId)
                .HasMaxLength(128)
                .HasComment("group_id")
                .HasColumnName("group_id");
            entity.Property(e => e.Id)
                .HasComment("id")
                .HasColumnName("id");
            entity.Property(e => e.TagName)
                .HasMaxLength(128)
                .HasComment("tag_name")
                .HasColumnName("tag_name");
            entity.Property(e => e.TagType)
                .HasMaxLength(64)
                .HasComment("tag_type")
                .HasColumnName("tag_type");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("tenant_id")
                .HasColumnName("tenant_id");
        });

        modelBuilder.Entity<Device>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("device");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.CurrentVersion)
                .HasMaxLength(255)
                .HasColumnName("current_version");
            entity.Property(e => e.Description)
                .HasMaxLength(100)
                .HasColumnName("description");
            entity.Property(e => e.DeviceTypeId).HasColumnName("device_type_id");
            entity.Property(e => e.Email)
                .HasMaxLength(255)
                .HasColumnName("email");
            entity.Property(e => e.FilePath)
                .HasMaxLength(255)
                .HasColumnName("file_path");
            entity.Property(e => e.GatewayId).HasColumnName("gateway_id");
            entity.Property(e => e.InstallDate)
                .HasMaxLength(6)
                .HasColumnName("install_date");
            entity.Property(e => e.LocLat).HasColumnName("loc_lat");
            entity.Property(e => e.LocLon).HasColumnName("loc_lon");
            entity.Property(e => e.Location)
                .HasMaxLength(100)
                .HasColumnName("location");
            entity.Property(e => e.Mac)
                .HasMaxLength(100)
                .HasColumnName("mac");
            entity.Property(e => e.Manufacture)
                .HasMaxLength(100)
                .HasColumnName("manufacture");
            entity.Property(e => e.Model)
                .HasMaxLength(100)
                .HasColumnName("model");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(100)
                .HasColumnName("name");
            entity.Property(e => e.NextVersion)
                .HasMaxLength(255)
                .HasColumnName("next_version");
            entity.Property(e => e.OilId).HasColumnName("oil_id");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.Phone)
                .HasMaxLength(255)
                .HasColumnName("phone");
            entity.Property(e => e.Status)
                .HasMaxLength(1)
                .IsFixedLength()
                .HasColumnName("status");
            entity.Property(e => e.SupertableName)
                .HasMaxLength(100)
                .HasColumnName("supertable_name");
            entity.Property(e => e.TName)
                .HasMaxLength(100)
                .HasColumnName("t_name");
            entity.Property(e => e.Type)
                .HasMaxLength(100)
                .HasColumnName("type");
            entity.Property(e => e.UpdateResult)
                .HasMaxLength(255)
                .HasColumnName("update_result");
            entity.Property(e => e.UpdateStatus)
                .HasColumnType("enum('NONE','PREPARE','DONE')")
                .HasColumnName("update_status");
            entity.Property(e => e.UpdateTime)
                .HasMaxLength(6)
                .HasColumnName("update_time");

            entity.HasMany(d => d.DevicePoints).WithMany(p => p.Devices)
                .UsingEntity<Dictionary<string, object>>(
                    "DeviceDevicePoint",
                    r => r.HasOne<SensorPoint>().WithMany()
                        .HasForeignKey("DevicePointId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKm19jk9kamke6wc0u8q3hujll1"),
                    l => l.HasOne<Device>().WithMany()
                        .HasForeignKey("DeviceId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKcdeusr820pxbtans82ts7gmsf"),
                    j =>
                    {
                        j.HasKey("DeviceId", "DevicePointId")
                            .HasName("PRIMARY")
                            .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
                        j.ToTable("device_device_point");
                        j.HasIndex(new[] { "DevicePointId" }, "FKm19jk9kamke6wc0u8q3hujll1");
                        j.IndexerProperty<long>("DeviceId").HasColumnName("device_id");
                        j.IndexerProperty<long>("DevicePointId").HasColumnName("device_point_id");
                    });

            entity.HasMany(d => d.Organizations).WithMany(p => p.Devices)
                .UsingEntity<Dictionary<string, object>>(
                    "DeviceOrganization",
                    r => r.HasOne<Organization>().WithMany()
                        .HasForeignKey("OrganizationId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKj17l4kq5nr8pxyreda9ducc1i"),
                    l => l.HasOne<Device>().WithMany()
                        .HasForeignKey("DeviceId")
                        .OnDelete(DeleteBehavior.ClientSetNull)
                        .HasConstraintName("FKg62c7fq9y4iefa8pbs4uww1t0"),
                    j =>
                    {
                        j.HasKey("DeviceId", "OrganizationId")
                            .HasName("PRIMARY")
                            .HasAnnotation("MySql:IndexPrefixLength", new[] { 0, 0 });
                        j.ToTable("device_organization");
                        j.HasIndex(new[] { "OrganizationId" }, "FKj17l4kq5nr8pxyreda9ducc1i");
                        j.IndexerProperty<long>("DeviceId").HasColumnName("device_id");
                        j.IndexerProperty<long>("OrganizationId").HasColumnName("organization_id");
                    });
        });

        modelBuilder.Entity<Device1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("devices")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.DeviceCode)
                .HasMaxLength(50)
                .HasComment("设备编号")
                .HasColumnName("device_code");
            entity.Property(e => e.DeviceFactory)
                .HasMaxLength(50)
                .HasComment("生产厂家")
                .HasColumnName("device_factory");
            entity.Property(e => e.DeviceMode)
                .HasMaxLength(50)
                .HasComment("设备型号")
                .HasColumnName("device_mode");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(50)
                .HasComment("设备名称")
                .HasColumnName("device_name");
            entity.Property(e => e.DevicePosition)
                .HasMaxLength(50)
                .HasComment("设备位置")
                .HasColumnName("device_position");
            entity.Property(e => e.DeviceType)
                .HasMaxLength(50)
                .HasComment("设备类型")
                .HasColumnName("device_type");
            entity.Property(e => e.Flag).HasColumnName("flag");
            entity.Property(e => e.InstallTime)
                .HasComment("安装时间")
                .HasColumnType("datetime")
                .HasColumnName("install_time");
            entity.Property(e => e.OilId).HasColumnName("oil_id");
            entity.Property(e => e.ParameterId).HasColumnName("parameter_id");
            entity.Property(e => e.Parentid).HasColumnName("parentid");
            entity.Property(e => e.SensorId).HasColumnName("sensor_id");
            entity.Property(e => e.WarnId).HasColumnName("warn_id");
            entity.Property(e => e.WarnIds)
                .HasMaxLength(50)
                .HasColumnName("warn_ids");
        });

        modelBuilder.Entity<DeviceGateway>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("device_gateway");

            entity.HasIndex(e => e.ServerId, "FKtqvbs4f7l3xxfn78v8tfbwbdc");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CodeNumber)
                .HasMaxLength(255)
                .HasColumnName("code_number");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.CurrentVersion)
                .HasMaxLength(255)
                .HasColumnName("current_version");
            entity.Property(e => e.FilePath)
                .HasMaxLength(255)
                .HasColumnName("file_path");
            entity.Property(e => e.Iccid)
                .HasMaxLength(255)
                .HasColumnName("iccid");
            entity.Property(e => e.Imei)
                .HasMaxLength(255)
                .HasColumnName("imei");
            entity.Property(e => e.Mac)
                .HasMaxLength(255)
                .HasColumnName("mac");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.NextVersion)
                .HasMaxLength(255)
                .HasColumnName("next_version");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.PubTopic)
                .HasMaxLength(255)
                .HasColumnName("pub_topic");
            entity.Property(e => e.ServerId).HasColumnName("server_id");
            entity.Property(e => e.Sn)
                .HasMaxLength(255)
                .HasColumnName("sn");
            entity.Property(e => e.Status)
                .HasMaxLength(1)
                .IsFixedLength()
                .HasColumnName("status");
            entity.Property(e => e.SubTopic)
                .HasMaxLength(255)
                .HasColumnName("sub_topic");
            entity.Property(e => e.TerminalCode)
                .HasMaxLength(255)
                .HasColumnName("terminal_code");
            entity.Property(e => e.TerminalModel)
                .HasMaxLength(255)
                .HasColumnName("terminal_model");
            entity.Property(e => e.TerminalName)
                .HasMaxLength(255)
                .HasColumnName("terminal_name");
            entity.Property(e => e.TerminalType)
                .HasMaxLength(255)
                .HasColumnName("terminal_type");
            entity.Property(e => e.UpdateResult)
                .HasMaxLength(255)
                .HasColumnName("update_result");
            entity.Property(e => e.UpdateStatus)
                .HasColumnType("enum('NONE','PREPARE','DONE')")
                .HasColumnName("update_status");
            entity.Property(e => e.UpdateTime)
                .HasColumnType("datetime")
                .HasColumnName("update_time");

            entity.HasOne(d => d.Server).WithMany(p => p.DeviceGateways)
                .HasForeignKey(d => d.ServerId)
                .HasConstraintName("FKtqvbs4f7l3xxfn78v8tfbwbdc");
        });

        modelBuilder.Entity<DeviceRule>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("device_rule");

            entity.HasIndex(e => new { e.DeviceId, e.RuleId }, "index2").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.RuleId).HasColumnName("rule_id");
        });

        modelBuilder.Entity<DeviceStatistic>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("device_statistics");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.StatisticsId).HasColumnName("statistics_id");
        });

        modelBuilder.Entity<DeviceType>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("device_type");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.TypeName)
                .HasMaxLength(255)
                .HasColumnName("type_name");
            entity.Property(e => e.TypeName1)
                .HasMaxLength(255)
                .HasColumnName("typeName");
        });

        modelBuilder.Entity<DevicesCopy1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("devices_copy1")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.DeviceCode)
                .HasMaxLength(50)
                .HasComment("设备编号")
                .HasColumnName("device_code");
            entity.Property(e => e.DeviceFactory)
                .HasMaxLength(50)
                .HasComment("生产厂家")
                .HasColumnName("device_factory");
            entity.Property(e => e.DeviceMode)
                .HasMaxLength(50)
                .HasComment("设备型号")
                .HasColumnName("device_mode");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(50)
                .HasComment("设备名称")
                .HasColumnName("device_name");
            entity.Property(e => e.DevicePosition)
                .HasMaxLength(50)
                .HasComment("设备位置")
                .HasColumnName("device_position");
            entity.Property(e => e.DeviceType)
                .HasMaxLength(50)
                .HasComment("设备类型")
                .HasColumnName("device_type");
            entity.Property(e => e.Flag).HasColumnName("flag");
            entity.Property(e => e.InstallTime)
                .HasComment("安装时间")
                .HasColumnType("datetime")
                .HasColumnName("install_time");
            entity.Property(e => e.Latitude)
                .HasComment("维度")
                .HasColumnName("latitude");
            entity.Property(e => e.Longitude)
                .HasComment("经度")
                .HasColumnName("longitude");
            entity.Property(e => e.OilId).HasColumnName("oil_id");
            entity.Property(e => e.Online).HasColumnName("online");
            entity.Property(e => e.ParameterId).HasColumnName("parameter_id");
            entity.Property(e => e.Parentid).HasColumnName("parentid");
            entity.Property(e => e.SensorId).HasColumnName("sensor_id");
            entity.Property(e => e.WarnId).HasColumnName("warn_id");
            entity.Property(e => e.WarnIds)
                .HasMaxLength(50)
                .HasColumnName("warn_ids");
        });

        modelBuilder.Entity<FuleInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("fule_info");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.BrandModel)
                .HasMaxLength(255)
                .HasColumnName("brand_model");
            entity.Property(e => e.Code)
                .HasMaxLength(255)
                .HasColumnName("code");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.FuelType)
                .HasMaxLength(255)
                .HasColumnName("fuel_type");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OilChangeCycle)
                .HasMaxLength(255)
                .HasColumnName("oil_change_cycle");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.RefuelingTime)
                .HasMaxLength(255)
                .HasColumnName("refueling_time");
            entity.Property(e => e.Status).HasColumnName("status");
        });

        modelBuilder.Entity<Gateway>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("gateways")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Flag)
                .HasComment("启用状态")
                .HasColumnName("flag");
            entity.Property(e => e.GatewayCode)
                .HasMaxLength(50)
                .HasComment("网关编码")
                .HasColumnName("gateway_code");
            entity.Property(e => e.GatewayMode)
                .HasMaxLength(50)
                .HasComment("网关型号")
                .HasColumnName("gateway_mode");
            entity.Property(e => e.GatewayName)
                .HasMaxLength(50)
                .HasComment("网关名称")
                .HasColumnName("gateway_name");
            entity.Property(e => e.GatewaySn)
                .HasMaxLength(50)
                .HasComment("网关SN")
                .HasColumnName("gateway_sn");
            entity.Property(e => e.GatewayType)
                .HasMaxLength(50)
                .HasComment("网关类型")
                .HasColumnName("gateway_type");
            entity.Property(e => e.SimSn)
                .HasMaxLength(50)
                .HasComment("物联卡号")
                .HasColumnName("sim_sn");
            entity.Property(e => e.Status)
                .HasComment("使用状态")
                .HasColumnName("status");
        });

        modelBuilder.Entity<GroupCapacity>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("group_capacity", tb => tb.HasComment("集群、各Group容量信息表"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => e.GroupId, "uk_group_id").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("主键ID")
                .HasColumnName("id");
            entity.Property(e => e.GmtCreate)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.GroupId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("Group ID，空字符表示整个集群")
                .HasColumnName("group_id");
            entity.Property(e => e.MaxAggrCount)
                .HasComment("聚合子配置最大个数，，0表示使用默认值")
                .HasColumnName("max_aggr_count");
            entity.Property(e => e.MaxAggrSize)
                .HasComment("单个聚合数据的子配置大小上限，单位为字节，0表示使用默认值")
                .HasColumnName("max_aggr_size");
            entity.Property(e => e.MaxHistoryCount)
                .HasComment("最大变更历史数量")
                .HasColumnName("max_history_count");
            entity.Property(e => e.MaxSize)
                .HasComment("单个配置大小上限，单位为字节，0表示使用默认值")
                .HasColumnName("max_size");
            entity.Property(e => e.Quota)
                .HasComment("配额，0表示使用默认值")
                .HasColumnName("quota");
            entity.Property(e => e.Usage)
                .HasComment("使用量")
                .HasColumnName("usage");
        });

        modelBuilder.Entity<HisConfigInfo>(entity =>
        {
            entity.HasKey(e => e.Nid).HasName("PRIMARY");

            entity
                .ToTable("his_config_info", tb => tb.HasComment("多租户改造"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => e.DataId, "idx_did");

            entity.HasIndex(e => e.GmtCreate, "idx_gmt_create");

            entity.HasIndex(e => e.GmtModified, "idx_gmt_modified");

            entity.Property(e => e.Nid).HasColumnName("nid");
            entity.Property(e => e.AppName)
                .HasMaxLength(128)
                .HasComment("app_name")
                .HasColumnName("app_name");
            entity.Property(e => e.Content).HasColumnName("content");
            entity.Property(e => e.DataId).HasColumnName("data_id");
            entity.Property(e => e.GmtCreate)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("datetime")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.GroupId)
                .HasMaxLength(128)
                .HasColumnName("group_id");
            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Md5)
                .HasMaxLength(32)
                .HasColumnName("md5");
            entity.Property(e => e.OpType)
                .HasMaxLength(10)
                .IsFixedLength()
                .HasColumnName("op_type");
            entity.Property(e => e.SrcIp)
                .HasMaxLength(20)
                .HasColumnName("src_ip");
            entity.Property(e => e.SrcUser)
                .HasColumnType("text")
                .HasColumnName("src_user");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("租户字段")
                .HasColumnName("tenant_id");
        });

        modelBuilder.Entity<Measurement>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("measurement");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Category)
                .HasMaxLength(255)
                .HasColumnName("category");
            entity.Property(e => e.Code)
                .HasMaxLength(255)
                .HasColumnName("code");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.DataType)
                .HasMaxLength(255)
                .HasColumnName("data_type");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.MeasurePrecision)
                .HasMaxLength(255)
                .HasColumnName("measure_precision");
            entity.Property(e => e.MeasureUnit)
                .HasMaxLength(255)
                .HasColumnName("measure_unit");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.Status).HasColumnName("status");
        });

        modelBuilder.Entity<Menu>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("menu");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Authority)
                .HasMaxLength(255)
                .HasColumnName("authority");
            entity.Property(e => e.Component)
                .HasMaxLength(255)
                .HasColumnName("component");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Icon)
                .HasMaxLength(255)
                .HasColumnName("icon");
            entity.Property(e => e.MenuRender)
                .HasColumnType("bit(1)")
                .HasColumnName("menu_render");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.ParentId).HasColumnName("parent_id");
            entity.Property(e => e.Path)
                .HasMaxLength(255)
                .HasColumnName("path");
        });

        modelBuilder.Entity<Menu1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("menus")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Flag).HasColumnName("flag");
            entity.Property(e => e.MenuName)
                .HasMaxLength(50)
                .HasColumnName("menu_name");
            entity.Property(e => e.MenuPath)
                .HasMaxLength(50)
                .HasColumnName("menu_path");
            entity.Property(e => e.Parentid).HasColumnName("parentid");
        });

        modelBuilder.Entity<Metric>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("metric");

            entity.HasIndex(e => e.DeviceId, "FK90wst8ef134yrfwh2uo747nvd");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Category)
                .HasMaxLength(255)
                .HasColumnName("category");
            entity.Property(e => e.Code)
                .HasMaxLength(255)
                .HasColumnName("code");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.DataType)
                .HasMaxLength(255)
                .HasColumnName("data_type");
            entity.Property(e => e.DataType1)
                .HasMaxLength(255)
                .HasColumnName("dataType");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.MetricPrecision)
                .HasMaxLength(255)
                .HasColumnName("metric_precision");
            entity.Property(e => e.MetricPrecision1)
                .HasMaxLength(255)
                .HasColumnName("metricPrecision");
            entity.Property(e => e.MetricUnit)
                .HasMaxLength(255)
                .HasColumnName("metric_unit");
            entity.Property(e => e.MetricUnit1)
                .HasMaxLength(255)
                .HasColumnName("metricUnit");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.OrganizationId1).HasColumnName("organizationId");
            entity.Property(e => e.Status)
                .HasMaxLength(255)
                .HasColumnName("status");

            entity.HasOne(d => d.Device).WithMany(p => p.Metrics)
                .HasForeignKey(d => d.DeviceId)
                .HasConstraintName("FK90wst8ef134yrfwh2uo747nvd");
        });

        modelBuilder.Entity<MetricGroup>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("metric_group");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
        });

        modelBuilder.Entity<MonitorDevice>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("monitor_device");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Code)
                .HasMaxLength(255)
                .HasColumnName("code");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.GatewayId).HasColumnName("gateway_id");
            entity.Property(e => e.GatewayId1).HasColumnName("gatewayId");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.PublicationTopic)
                .HasMaxLength(255)
                .HasColumnName("publication_topic");
            entity.Property(e => e.PublicationTopic1)
                .HasMaxLength(255)
                .HasColumnName("publicationTopic");
            entity.Property(e => e.Sn)
                .HasMaxLength(255)
                .HasColumnName("sn");
            entity.Property(e => e.Status).HasColumnName("status");
            entity.Property(e => e.SubscriptionTopic)
                .HasMaxLength(255)
                .HasColumnName("subscription_topic");
            entity.Property(e => e.SubscriptionTopic1)
                .HasMaxLength(255)
                .HasColumnName("subscriptionTopic");
            entity.Property(e => e.TerminalCategory)
                .HasMaxLength(255)
                .HasColumnName("terminal_category");
            entity.Property(e => e.TerminalCategory1)
                .HasMaxLength(255)
                .HasColumnName("terminalCategory");
            entity.Property(e => e.TerminalType)
                .HasMaxLength(255)
                .HasColumnName("terminal_type");
            entity.Property(e => e.TerminalType1)
                .HasMaxLength(255)
                .HasColumnName("terminalType");
        });

        modelBuilder.Entity<MonitorPoint>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("monitor_point");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.AlertRuleId).HasColumnName("alert_rule_id");
            entity.Property(e => e.AlertRuleId1).HasColumnName("alertRuleId");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.CreationDate)
                .HasMaxLength(6)
                .HasColumnName("creation_date");
            entity.Property(e => e.CreationDate1)
                .HasMaxLength(6)
                .HasColumnName("creationDate");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.DeviceId1).HasColumnName("deviceId");
            entity.Property(e => e.FuelId).HasColumnName("fuel_id");
            entity.Property(e => e.FuelId1).HasColumnName("fuelId");
            entity.Property(e => e.GatewayId).HasColumnName("gateway_id");
            entity.Property(e => e.GatewayId1).HasColumnName("gatewayId");
            entity.Property(e => e.MeasurementId).HasColumnName("measurement_id");
            entity.Property(e => e.MeasurementId1).HasColumnName("measurementId");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.OrganizationId1).HasColumnName("organizationId");
            entity.Property(e => e.PointCode)
                .HasMaxLength(255)
                .HasColumnName("point_code");
            entity.Property(e => e.PointCode1)
                .HasMaxLength(255)
                .HasColumnName("pointCode");
            entity.Property(e => e.PointLocation)
                .HasMaxLength(255)
                .HasColumnName("point_location");
            entity.Property(e => e.PointLocation1)
                .HasMaxLength(255)
                .HasColumnName("pointLocation");
            entity.Property(e => e.PointName)
                .HasMaxLength(255)
                .HasColumnName("point_name");
            entity.Property(e => e.PointName1)
                .HasMaxLength(255)
                .HasColumnName("pointName");
            entity.Property(e => e.Status).HasColumnName("status");
        });

        modelBuilder.Entity<Oil>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("oils")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Flag).HasColumnName("flag");
            entity.Property(e => e.OilChangeInterval).HasColumnName("oil_change_interval");
            entity.Property(e => e.OilCode)
                .HasMaxLength(50)
                .HasColumnName("oil_code");
            entity.Property(e => e.OilFillTime)
                .HasColumnType("datetime")
                .HasColumnName("oil_fill_time");
            entity.Property(e => e.OilIndexA)
                .HasPrecision(18, 3)
                .HasColumnName("oil_indexA");
            entity.Property(e => e.OilIndexB)
                .HasPrecision(18, 3)
                .HasColumnName("oil_indexB");
            entity.Property(e => e.OilMode)
                .HasMaxLength(50)
                .HasColumnName("oil_mode");
            entity.Property(e => e.OilName)
                .HasMaxLength(50)
                .HasColumnName("oil_name");
            entity.Property(e => e.OilType)
                .HasMaxLength(50)
                .HasColumnName("oil_type");
        });

        modelBuilder.Entity<OilInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("oil_info");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Code)
                .HasMaxLength(255)
                .HasColumnName("code");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OilChangeCycle)
                .HasMaxLength(255)
                .HasColumnName("oil_change_cycle");
            entity.Property(e => e.OilGrade)
                .HasMaxLength(255)
                .HasColumnName("oil_grade");
            entity.Property(e => e.OilType)
                .HasMaxLength(255)
                .HasColumnName("oil_type");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.RefuelingTime).HasColumnName("refueling_time");
            entity.Property(e => e.Status)
                .HasMaxLength(255)
                .HasColumnName("status");
            entity.Property(e => e.ViscosityCoefficientA1).HasColumnName("viscosity_coefficient_a");
            entity.Property(e => e.ViscosityCoefficientB1).HasColumnName("viscosity_coefficient_b");
            entity.Property(e => e.ViscosityCoefficienta).HasColumnName("viscosity_coefficienta");
            entity.Property(e => e.ViscosityCoefficientb).HasColumnName("viscosity_coefficientb");
        });

        modelBuilder.Entity<Organization>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("organization");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Address)
                .HasMaxLength(255)
                .HasColumnName("address");
            entity.Property(e => e.ContractEmail)
                .HasMaxLength(255)
                .HasColumnName("contract_email");
            entity.Property(e => e.ContractName)
                .HasMaxLength(255)
                .HasColumnName("contract_name");
            entity.Property(e => e.ContractPhone)
                .HasMaxLength(255)
                .HasColumnName("contract_phone");
            entity.Property(e => e.CreatedAt)
                .HasColumnType("datetime")
                .HasColumnName("created_at");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.IsTrial)
                .HasColumnType("bit(1)")
                .HasColumnName("is_trial");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.OrgName)
                .HasMaxLength(255)
                .HasColumnName("org_name");
            entity.Property(e => e.ParentId).HasColumnName("parent_id");
            entity.Property(e => e.SupertableName)
                .HasMaxLength(45)
                .HasColumnName("supertable_name");
        });

        modelBuilder.Entity<OrganizationRole>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("organization_role");

            entity.HasIndex(e => e.RoleId, "FK3b7pk6bybqk3xsmpq0umsmdi1");

            entity.HasIndex(e => e.OrganizationId, "FKt51xpvlldba9k2j266ln6ropu");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.RoleId).HasColumnName("role_id");

            entity.HasOne(d => d.Organization).WithMany(p => p.OrganizationRoles)
                .HasForeignKey(d => d.OrganizationId)
                .HasConstraintName("FKt51xpvlldba9k2j266ln6ropu");

            entity.HasOne(d => d.Role).WithMany(p => p.OrganizationRoles)
                .HasForeignKey(d => d.RoleId)
                .HasConstraintName("FK3b7pk6bybqk3xsmpq0umsmdi1");
        });

        modelBuilder.Entity<Parameter>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("parameters")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Flag)
                .HasComment("启用状态")
                .HasColumnName("flag");
            entity.Property(e => e.ParameterAttribute)
                .HasMaxLength(50)
                .HasComment("描述")
                .HasColumnName("parameter_attribute");
            entity.Property(e => e.ParameterCode)
                .HasMaxLength(50)
                .HasColumnName("parameter_code");
            entity.Property(e => e.ParameterDatatype)
                .HasMaxLength(50)
                .HasComment("数据类型")
                .HasColumnName("parameter_datatype");
            entity.Property(e => e.ParameterName)
                .HasMaxLength(50)
                .HasColumnName("parameter_name");
            entity.Property(e => e.ParameterPoint)
                .HasMaxLength(50)
                .HasComment("分辨率(小数点位数)")
                .HasColumnName("parameter_point");
            entity.Property(e => e.ParameterType)
                .HasMaxLength(50)
                .HasComment("分类(online/offline)")
                .HasColumnName("parameter_type");
            entity.Property(e => e.ParameterUnit)
                .HasMaxLength(50)
                .HasComment("单位")
                .HasColumnName("parameter_unit");
        });

        modelBuilder.Entity<Permission>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("permissions");

            entity.HasIndex(e => new { e.Role, e.Resource, e.Action }, "uk_role_permission").IsUnique();

            entity.Property(e => e.Action)
                .HasMaxLength(8)
                .HasColumnName("action");
            entity.Property(e => e.Resource)
                .HasMaxLength(512)
                .HasColumnName("resource");
            entity.Property(e => e.Role)
                .HasMaxLength(50)
                .HasColumnName("role");
        });

        modelBuilder.Entity<Power>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("powers")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.FunctionId).HasColumnName("function_id");
            entity.Property(e => e.Parentid).HasColumnName("parentid");
            entity.Property(e => e.PowerName)
                .HasMaxLength(50)
                .HasColumnName("power_name");
        });

        modelBuilder.Entity<Role>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("role");

            entity.HasIndex(e => e.AccountId, "FKm7tjaj4k18apvr1raulwdgd3");

            entity.HasIndex(e => e.OrganizationId, "FKp43um38ltwpmq21oflfntlde0");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.AccountId).HasColumnName("account_id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");

            entity.HasOne(d => d.Account).WithMany(p => p.Roles)
                .HasForeignKey(d => d.AccountId)
                .HasConstraintName("FKm7tjaj4k18apvr1raulwdgd3");

            entity.HasOne(d => d.Organization).WithMany(p => p.Roles)
                .HasForeignKey(d => d.OrganizationId)
                .HasConstraintName("FKp43um38ltwpmq21oflfntlde0");
        });

        modelBuilder.Entity<Role1>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("roles");

            entity.HasIndex(e => new { e.Username, e.Role }, "idx_user_role").IsUnique();

            entity.Property(e => e.Role)
                .HasMaxLength(50)
                .HasColumnName("role");
            entity.Property(e => e.Username)
                .HasMaxLength(50)
                .HasColumnName("username");
        });

        modelBuilder.Entity<RoleMenu>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("role_menu");

            entity.HasIndex(e => e.MenuId, "FKfg4e2mb2318tph615gh44ll3");

            entity.HasIndex(e => e.RoleId, "FKqyvxw2gg2qk0wld3bqfcb58vq");

            entity.Property(e => e.MenuId).HasColumnName("menu_id");
            entity.Property(e => e.RoleId).HasColumnName("role_id");

            entity.HasOne(d => d.Menu).WithMany()
                .HasForeignKey(d => d.MenuId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKfg4e2mb2318tph615gh44ll3");

            entity.HasOne(d => d.Role).WithMany()
                .HasForeignKey(d => d.RoleId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKqyvxw2gg2qk0wld3bqfcb58vq");
        });

        modelBuilder.Entity<Rule>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("rules")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Flag)
                .HasComment("启用状态")
                .HasColumnName("flag");
            entity.Property(e => e.LowerLowerValue)
                .HasMaxLength(50)
                .HasColumnName("lower_lower_value");
            entity.Property(e => e.LowerValue)
                .HasMaxLength(50)
                .HasColumnName("lower_value");
            entity.Property(e => e.ParameterId).HasColumnName("parameter_id");
            entity.Property(e => e.RuleCode)
                .HasMaxLength(50)
                .HasColumnName("rule_code");
            entity.Property(e => e.SensorId).HasColumnName("sensor_id");
            entity.Property(e => e.UpperUpperValue)
                .HasMaxLength(50)
                .HasColumnName("upper_upper_value");
            entity.Property(e => e.UpperValue)
                .HasMaxLength(50)
                .HasColumnName("upper_value");
        });

        modelBuilder.Entity<RuleEntity>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("rule_entity");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.Parameters)
                .HasMaxLength(255)
                .HasColumnName("parameters");
            entity.Property(e => e.RuleAction)
                .HasMaxLength(255)
                .HasColumnName("rule_action");
            entity.Property(e => e.RuleCondition)
                .HasMaxLength(255)
                .HasColumnName("rule_condition");
            entity.Property(e => e.RulePriority).HasColumnName("rule_priority");
            entity.Property(e => e.RuleType)
                .HasColumnType("enum('WARNING','ALARM')")
                .HasColumnName("rule_type");
            entity.Property(e => e.Sink)
                .HasMaxLength(255)
                .HasColumnName("sink");
            entity.Property(e => e.Status)
                .HasMaxLength(1)
                .IsFixedLength()
                .HasColumnName("status");
        });

        modelBuilder.Entity<Sensor>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("sensors")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Flag)
                .HasComment("启用状态")
                .HasColumnName("flag");
            entity.Property(e => e.GatewayId)
                .HasMaxLength(50)
                .HasComment("网关ID")
                .HasColumnName("gateway_id");
            entity.Property(e => e.OnlineStatus)
                .HasComment("使用状态")
                .HasColumnName("online_status");
            entity.Property(e => e.SensorCode)
                .HasMaxLength(50)
                .HasComment("终端编码")
                .HasColumnName("sensor_code");
            entity.Property(e => e.SensorMode)
                .HasMaxLength(50)
                .HasComment("终端类型")
                .HasColumnName("sensor_mode");
            entity.Property(e => e.SensorName)
                .HasMaxLength(50)
                .HasComment("终端名称")
                .HasColumnName("sensor_name");
            entity.Property(e => e.SensorSn)
                .HasMaxLength(50)
                .HasComment("终端序列号")
                .HasColumnName("sensor_sn");
            entity.Property(e => e.SensorSubscribe)
                .HasMaxLength(50)
                .HasComment("终端订阅")
                .HasColumnName("sensor_subscribe");
            entity.Property(e => e.SensorTopic)
                .HasMaxLength(50)
                .HasComment("终端主题")
                .HasColumnName("sensor_topic");
            entity.Property(e => e.SensorType)
                .HasMaxLength(50)
                .HasComment("终端分类")
                .HasColumnName("sensor_type");
        });

        modelBuilder.Entity<SensorPoint>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("sensor_point");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.DeviceTypeId).HasColumnName("device_type_id");
            entity.Property(e => e.DisplayOrder).HasColumnName("display_order");
            entity.Property(e => e.Fixed)
                .HasColumnType("bit(1)")
                .HasColumnName("fixed");
            entity.Property(e => e.IsHiden)
                .HasColumnType("bit(1)")
                .HasColumnName("is_hiden");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
            entity.Property(e => e.PointName)
                .HasMaxLength(255)
                .HasColumnName("point_name");
            entity.Property(e => e.StandardizedName)
                .HasMaxLength(255)
                .HasColumnName("standardized_name");
            entity.Property(e => e.Type)
                .HasColumnType("enum('INT','INT16','INT32','INT64','FLOAT','DOUBLE','STRING','Object')")
                .HasColumnName("type");
            entity.Property(e => e.Unit)
                .HasMaxLength(255)
                .HasColumnName("unit");
        });

        modelBuilder.Entity<Sensordata>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("sensordatas")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Aw).HasColumnName("aw");
            entity.Property(e => e.BufferTemper).HasColumnName("buffer_temper");
            entity.Property(e => e.Class1).HasColumnName("class1");
            entity.Property(e => e.Class2).HasColumnName("class2");
            entity.Property(e => e.Class3).HasColumnName("class3");
            entity.Property(e => e.Class4).HasColumnName("class4");
            entity.Property(e => e.Class5).HasColumnName("class5");
            entity.Property(e => e.Class6).HasColumnName("class6");
            entity.Property(e => e.ClassTotal).HasColumnName("class_total");
            entity.Property(e => e.CreateTime)
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.Dens).HasColumnName("dens");
            entity.Property(e => e.DeviceCode)
                .HasMaxLength(50)
                .HasColumnName("device_code");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(50)
                .HasColumnName("device_name");
            entity.Property(e => e.Diel).HasColumnName("diel");
            entity.Property(e => e.Fe).HasColumnName("fe");
            entity.Property(e => e.Fe1).HasColumnName("fe1");
            entity.Property(e => e.Fe10).HasColumnName("fe10");
            entity.Property(e => e.Fe2).HasColumnName("fe2");
            entity.Property(e => e.Fe3).HasColumnName("fe3");
            entity.Property(e => e.Fe4).HasColumnName("fe4");
            entity.Property(e => e.Fe5).HasColumnName("fe5");
            entity.Property(e => e.Fe6).HasColumnName("fe6");
            entity.Property(e => e.Fe7).HasColumnName("fe7");
            entity.Property(e => e.Fe8).HasColumnName("fe8");
            entity.Property(e => e.Fe9).HasColumnName("fe9");
            entity.Property(e => e.Mo).HasColumnName("mo");
            entity.Property(e => e.Nfe).HasColumnName("nfe");
            entity.Property(e => e.Nfe1).HasColumnName("nfe1");
            entity.Property(e => e.Nfe2).HasColumnName("nfe2");
            entity.Property(e => e.Nfe3).HasColumnName("nfe3");
            entity.Property(e => e.Nfe4).HasColumnName("nfe4");
            entity.Property(e => e.Nfe5).HasColumnName("nfe5");
            entity.Property(e => e.Par1).HasColumnName("par1");
            entity.Property(e => e.Par2).HasColumnName("par2");
            entity.Property(e => e.Par3).HasColumnName("par3");
            entity.Property(e => e.Par4).HasColumnName("par4");
            entity.Property(e => e.Par5).HasColumnName("par5");
            entity.Property(e => e.Par6).HasColumnName("par6");
            entity.Property(e => e.Par7).HasColumnName("par7");
            entity.Property(e => e.Par8).HasColumnName("par8");
            entity.Property(e => e.Ppm).HasColumnName("ppm");
            entity.Property(e => e.Press).HasColumnName("press");
            entity.Property(e => e.SensorSn)
                .HasMaxLength(50)
                .HasColumnName("sensor_sn");
            entity.Property(e => e.Speed).HasColumnName("speed");
            entity.Property(e => e.Standard).HasColumnName("standard");
            entity.Property(e => e.State).HasColumnName("state");
            entity.Property(e => e.Temper).HasColumnName("temper");
            entity.Property(e => e.Vis).HasColumnName("vis");
            entity.Property(e => e.Vis40).HasColumnName("vis40");
        });

        modelBuilder.Entity<SensordatasCopy1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("sensordatas_copy1")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Aw).HasColumnName("aw");
            entity.Property(e => e.BufferTemper).HasColumnName("buffer_temper");
            entity.Property(e => e.Class1).HasColumnName("class1");
            entity.Property(e => e.Class2).HasColumnName("class2");
            entity.Property(e => e.Class3).HasColumnName("class3");
            entity.Property(e => e.Class4).HasColumnName("class4");
            entity.Property(e => e.Class5).HasColumnName("class5");
            entity.Property(e => e.Class6).HasColumnName("class6");
            entity.Property(e => e.ClassTotal).HasColumnName("class_total");
            entity.Property(e => e.CreateTime)
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.Dens).HasColumnName("dens");
            entity.Property(e => e.DeviceCode)
                .HasMaxLength(50)
                .HasColumnName("device_code");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(50)
                .HasColumnName("device_name");
            entity.Property(e => e.Diel).HasColumnName("diel");
            entity.Property(e => e.Fe).HasColumnName("fe");
            entity.Property(e => e.Fe1).HasColumnName("fe1");
            entity.Property(e => e.Fe10).HasColumnName("fe10");
            entity.Property(e => e.Fe2).HasColumnName("fe2");
            entity.Property(e => e.Fe3).HasColumnName("fe3");
            entity.Property(e => e.Fe4).HasColumnName("fe4");
            entity.Property(e => e.Fe5).HasColumnName("fe5");
            entity.Property(e => e.Fe6).HasColumnName("fe6");
            entity.Property(e => e.Fe7).HasColumnName("fe7");
            entity.Property(e => e.Fe8).HasColumnName("fe8");
            entity.Property(e => e.Fe9).HasColumnName("fe9");
            entity.Property(e => e.Mo).HasColumnName("mo");
            entity.Property(e => e.Nfe).HasColumnName("nfe");
            entity.Property(e => e.Nfe1).HasColumnName("nfe1");
            entity.Property(e => e.Nfe2).HasColumnName("nfe2");
            entity.Property(e => e.Nfe3).HasColumnName("nfe3");
            entity.Property(e => e.Nfe4).HasColumnName("nfe4");
            entity.Property(e => e.Nfe5).HasColumnName("nfe5");
            entity.Property(e => e.Par1).HasColumnName("par1");
            entity.Property(e => e.Par2).HasColumnName("par2");
            entity.Property(e => e.Par3).HasColumnName("par3");
            entity.Property(e => e.Par4).HasColumnName("par4");
            entity.Property(e => e.Par5).HasColumnName("par5");
            entity.Property(e => e.Par6).HasColumnName("par6");
            entity.Property(e => e.Par7).HasColumnName("par7");
            entity.Property(e => e.Par8).HasColumnName("par8");
            entity.Property(e => e.Ppm).HasColumnName("ppm");
            entity.Property(e => e.Press).HasColumnName("press");
            entity.Property(e => e.SensorSn)
                .HasMaxLength(50)
                .HasColumnName("sensor_sn");
            entity.Property(e => e.Speed).HasColumnName("speed");
            entity.Property(e => e.Standard).HasColumnName("standard");
            entity.Property(e => e.State).HasColumnName("state");
            entity.Property(e => e.Temper).HasColumnName("temper");
            entity.Property(e => e.Vis).HasColumnName("vis");
            entity.Property(e => e.Vis40).HasColumnName("vis40");
        });

        modelBuilder.Entity<SensorsCopy1>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("sensors_copy1")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Flag).HasColumnName("flag");
            entity.Property(e => e.GatewayId)
                .HasMaxLength(50)
                .HasColumnName("gateway_id");
            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.SensorCode)
                .HasMaxLength(50)
                .HasColumnName("sensor_code");
            entity.Property(e => e.SensorMode)
                .HasMaxLength(50)
                .HasColumnName("sensor_mode");
            entity.Property(e => e.SensorName)
                .HasMaxLength(50)
                .HasColumnName("sensor_name");
            entity.Property(e => e.SensorSn)
                .HasMaxLength(50)
                .HasColumnName("sensor_sn");
            entity.Property(e => e.SensorSubscribe)
                .HasMaxLength(50)
                .HasColumnName("sensor_subscribe");
            entity.Property(e => e.SensorTopic)
                .HasMaxLength(50)
                .HasColumnName("sensor_topic");
            entity.Property(e => e.SensorType)
                .HasMaxLength(50)
                .HasColumnName("sensor_type");
        });

        modelBuilder.Entity<Sensorsstateinfo>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("sensorsstateinfo")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Aw).HasColumnName("aw");
            entity.Property(e => e.BufferTemper).HasColumnName("buffer_temper");
            entity.Property(e => e.Class1).HasColumnName("class1");
            entity.Property(e => e.Class2).HasColumnName("class2");
            entity.Property(e => e.Class3).HasColumnName("class3");
            entity.Property(e => e.Class4).HasColumnName("class4");
            entity.Property(e => e.Class5).HasColumnName("class5");
            entity.Property(e => e.Class6).HasColumnName("class6");
            entity.Property(e => e.ClassTotal).HasColumnName("class_total");
            entity.Property(e => e.CreateTime)
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.Dens).HasColumnName("dens");
            entity.Property(e => e.DeviceCode)
                .HasMaxLength(50)
                .HasColumnName("device_code");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(50)
                .HasColumnName("device_name");
            entity.Property(e => e.Diel).HasColumnName("diel");
            entity.Property(e => e.Fe).HasColumnName("fe");
            entity.Property(e => e.Fe1).HasColumnName("fe1");
            entity.Property(e => e.Fe10).HasColumnName("fe10");
            entity.Property(e => e.Fe2).HasColumnName("fe2");
            entity.Property(e => e.Fe3).HasColumnName("fe3");
            entity.Property(e => e.Fe4).HasColumnName("fe4");
            entity.Property(e => e.Fe5).HasColumnName("fe5");
            entity.Property(e => e.Fe6).HasColumnName("fe6");
            entity.Property(e => e.Fe7).HasColumnName("fe7");
            entity.Property(e => e.Fe8).HasColumnName("fe8");
            entity.Property(e => e.Fe9).HasColumnName("fe9");
            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Mo).HasColumnName("mo");
            entity.Property(e => e.Nfe).HasColumnName("nfe");
            entity.Property(e => e.Nfe1).HasColumnName("nfe1");
            entity.Property(e => e.Nfe2).HasColumnName("nfe2");
            entity.Property(e => e.Nfe3).HasColumnName("nfe3");
            entity.Property(e => e.Nfe4).HasColumnName("nfe4");
            entity.Property(e => e.Nfe5).HasColumnName("nfe5");
            entity.Property(e => e.Par1).HasColumnName("par1");
            entity.Property(e => e.Par2).HasColumnName("par2");
            entity.Property(e => e.Par3).HasColumnName("par3");
            entity.Property(e => e.Par4).HasColumnName("par4");
            entity.Property(e => e.Par5).HasColumnName("par5");
            entity.Property(e => e.Par6).HasColumnName("par6");
            entity.Property(e => e.Par7).HasColumnName("par7");
            entity.Property(e => e.Par8).HasColumnName("par8");
            entity.Property(e => e.Ppm).HasColumnName("ppm");
            entity.Property(e => e.Press).HasColumnName("press");
            entity.Property(e => e.SensorSn)
                .HasMaxLength(50)
                .HasColumnName("sensor_sn");
            entity.Property(e => e.Speed).HasColumnName("speed");
            entity.Property(e => e.Standard).HasColumnName("standard");
            entity.Property(e => e.State).HasColumnName("state");
            entity.Property(e => e.Temper).HasColumnName("temper");
            entity.Property(e => e.Vis).HasColumnName("vis");
            entity.Property(e => e.Vis40).HasColumnName("vis40");
        });

        modelBuilder.Entity<Server>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("server");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Host)
                .HasMaxLength(255)
                .HasColumnName("host");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Password)
                .HasMaxLength(255)
                .HasColumnName("password");
            entity.Property(e => e.Type)
                .HasColumnType("enum('MQTT','MQTTS','HTTPS','HTTP')")
                .HasColumnName("type");
            entity.Property(e => e.Username)
                .HasMaxLength(255)
                .HasColumnName("username");
        });

        modelBuilder.Entity<Statistic>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("statistics");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Content)
                .HasMaxLength(255)
                .HasColumnName("content");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasColumnName("name");
            entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
        });

        modelBuilder.Entity<TenantCapacity>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("tenant_capacity", tb => tb.HasComment("租户容量信息表"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => e.TenantId, "uk_tenant_id").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("主键ID")
                .HasColumnName("id");
            entity.Property(e => e.GmtCreate)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasComment("修改时间")
                .HasColumnType("datetime")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.MaxAggrCount)
                .HasComment("聚合子配置最大个数")
                .HasColumnName("max_aggr_count");
            entity.Property(e => e.MaxAggrSize)
                .HasComment("单个聚合数据的子配置大小上限，单位为字节，0表示使用默认值")
                .HasColumnName("max_aggr_size");
            entity.Property(e => e.MaxHistoryCount)
                .HasComment("最大变更历史数量")
                .HasColumnName("max_history_count");
            entity.Property(e => e.MaxSize)
                .HasComment("单个配置大小上限，单位为字节，0表示使用默认值")
                .HasColumnName("max_size");
            entity.Property(e => e.Quota)
                .HasComment("配额，0表示使用默认值")
                .HasColumnName("quota");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("Tenant ID")
                .HasColumnName("tenant_id");
            entity.Property(e => e.Usage)
                .HasComment("使用量")
                .HasColumnName("usage");
        });

        modelBuilder.Entity<TenantInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("tenant_info", tb => tb.HasComment("tenant_info"))
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_bin");

            entity.HasIndex(e => e.TenantId, "idx_tenant_id");

            entity.HasIndex(e => new { e.Kp, e.TenantId }, "uk_tenant_info_kptenantid").IsUnique();

            entity.Property(e => e.Id)
                .HasComment("id")
                .HasColumnName("id");
            entity.Property(e => e.CreateSource)
                .HasMaxLength(32)
                .HasComment("create_source")
                .HasColumnName("create_source");
            entity.Property(e => e.GmtCreate)
                .HasComment("创建时间")
                .HasColumnName("gmt_create");
            entity.Property(e => e.GmtModified)
                .HasComment("修改时间")
                .HasColumnName("gmt_modified");
            entity.Property(e => e.Kp)
                .HasMaxLength(128)
                .HasComment("kp")
                .HasColumnName("kp");
            entity.Property(e => e.TenantDesc)
                .HasMaxLength(256)
                .HasComment("tenant_desc")
                .HasColumnName("tenant_desc");
            entity.Property(e => e.TenantId)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("tenant_id")
                .HasColumnName("tenant_id");
            entity.Property(e => e.TenantName)
                .HasMaxLength(128)
                .HasDefaultValueSql("''")
                .HasComment("tenant_name")
                .HasColumnName("tenant_name");
        });

        modelBuilder.Entity<UpdateFile>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("update_file");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.Description)
                .HasMaxLength(255)
                .HasColumnName("description");
            entity.Property(e => e.Descrption)
                .HasMaxLength(255)
                .HasColumnName("descrption");
            entity.Property(e => e.FileName1)
                .HasMaxLength(255)
                .HasColumnName("file_name");
            entity.Property(e => e.Filename)
                .HasMaxLength(255)
                .HasColumnName("filename");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Path)
                .HasMaxLength(255)
                .HasColumnName("path");
            entity.Property(e => e.Version)
                .HasMaxLength(255)
                .HasColumnName("version");
        });

        modelBuilder.Entity<UpdateMessage>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("update_message");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.CurrentNumber).HasColumnName("current_number");
            entity.Property(e => e.CurrentNumber1).HasColumnName("currentNumber");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.Payload)
                .HasColumnType("tinyblob")
                .HasColumnName("payload");
            entity.Property(e => e.Status)
                .HasMaxLength(255)
                .HasColumnName("status");
            entity.Property(e => e.TaskId).HasColumnName("task_id");
            entity.Property(e => e.TaskId1).HasColumnName("taskId");
            entity.Property(e => e.Topic)
                .HasMaxLength(255)
                .HasColumnName("topic");
            entity.Property(e => e.TotalNumber).HasColumnName("total_number");
            entity.Property(e => e.TotalNumber1).HasColumnName("totalNumber");
            entity.Property(e => e.Uuid)
                .HasMaxLength(255)
                .HasColumnName("uuid");
        });

        modelBuilder.Entity<UpdateTask>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("update_task");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasColumnType("datetime")
                .HasColumnName("create_at");
            entity.Property(e => e.DeviceGatewayName)
                .HasMaxLength(255)
                .HasColumnName("device_gateway_name");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(255)
                .HasColumnName("device_name");
            entity.Property(e => e.FileId).HasColumnName("file_id");
            entity.Property(e => e.Header)
                .HasColumnType("tinyblob")
                .HasColumnName("header");
            entity.Property(e => e.ModifyAt)
                .HasColumnType("datetime")
                .HasColumnName("modify_at");
            entity.Property(e => e.PubTopic)
                .HasMaxLength(255)
                .HasColumnName("pub_topic");
            entity.Property(e => e.Status)
                .HasMaxLength(255)
                .HasColumnName("status");
            entity.Property(e => e.SubTopic)
                .HasMaxLength(255)
                .HasColumnName("sub_topic");
            entity.Property(e => e.Topic)
                .HasMaxLength(255)
                .HasColumnName("topic");
            entity.Property(e => e.TotalNumber).HasColumnName("total_number");
            entity.Property(e => e.UpdateFile)
                .HasMaxLength(255)
                .HasColumnName("update_file");
            entity.Property(e => e.Uuid)
                .HasMaxLength(255)
                .HasColumnName("uuid");
        });

        modelBuilder.Entity<Updatetask1>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("updatetask");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.CreateAt)
                .HasMaxLength(6)
                .HasColumnName("create_at");
            entity.Property(e => e.DeviceId).HasColumnName("device_id");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(255)
                .HasColumnName("device_name");
            entity.Property(e => e.FileId).HasColumnName("file_id");
            entity.Property(e => e.Header)
                .HasColumnType("tinyblob")
                .HasColumnName("header");
            entity.Property(e => e.ModifyAt)
                .HasMaxLength(6)
                .HasColumnName("modify_at");
            entity.Property(e => e.PubTopic)
                .HasMaxLength(255)
                .HasColumnName("pub_topic");
            entity.Property(e => e.Status)
                .HasMaxLength(255)
                .HasColumnName("status");
            entity.Property(e => e.SubTopic)
                .HasMaxLength(255)
                .HasColumnName("sub_topic");
            entity.Property(e => e.TotalNumber).HasColumnName("total_number");
            entity.Property(e => e.UpdateFile)
                .HasMaxLength(255)
                .HasColumnName("update_file");
            entity.Property(e => e.Uuid)
                .HasMaxLength(255)
                .HasColumnName("uuid");
        });

        modelBuilder.Entity<User>(entity =>
        {
            entity.HasKey(e => e.Username).HasName("PRIMARY");

            entity.ToTable("users");

            entity.Property(e => e.Username)
                .HasMaxLength(50)
                .HasColumnName("username");
            entity.Property(e => e.Enabled).HasColumnName("enabled");
            entity.Property(e => e.Password)
                .HasMaxLength(500)
                .HasColumnName("password");
        });

        modelBuilder.Entity<Warningdata>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("warningdatas")
                .HasCharSet("utf8mb3")
                .UseCollation("utf8mb3_general_ci");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("id");
            entity.Property(e => e.Aw).HasColumnName("aw");
            entity.Property(e => e.Dens).HasColumnName("dens");
            entity.Property(e => e.DeviceCode)
                .HasMaxLength(50)
                .HasColumnName("device_code");
            entity.Property(e => e.DeviceName)
                .HasMaxLength(50)
                .HasColumnName("device_name");
            entity.Property(e => e.Diel).HasColumnName("diel");
            entity.Property(e => e.Fe).HasColumnName("fe");
            entity.Property(e => e.Flag).HasColumnName("flag");
            entity.Property(e => e.Iso).HasColumnName("iso");
            entity.Property(e => e.Mo).HasColumnName("mo");
            entity.Property(e => e.Nfe).HasColumnName("nfe");
            entity.Property(e => e.ParameterCode)
                .HasMaxLength(50)
                .HasColumnName("parameter_code");
            entity.Property(e => e.Ppm).HasColumnName("ppm");
            entity.Property(e => e.RemoveTime)
                .HasColumnType("datetime")
                .HasColumnName("remove_time");
            entity.Property(e => e.SensorSn)
                .HasMaxLength(50)
                .HasColumnName("sensor_sn");
            entity.Property(e => e.SensordataId).HasColumnName("sensordata_id");
            entity.Property(e => e.Statu)
                .HasMaxLength(10)
                .IsFixedLength()
                .HasColumnName("statu");
            entity.Property(e => e.Status).HasColumnName("status");
            entity.Property(e => e.Temper).HasColumnName("temper");
            entity.Property(e => e.UserId).HasColumnName("user_id");
            entity.Property(e => e.Value).HasColumnName("value");
            entity.Property(e => e.Vis).HasColumnName("vis");
            entity.Property(e => e.Vis40).HasColumnName("vis40");
            entity.Property(e => e.WarnTime)
                .HasColumnType("datetime")
                .HasColumnName("warn_time");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
